package com.huizu.pay.util.pay.AliPay;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.CertAlipayRequest;
import com.alipay.api.DefaultAlipayClient;

public class PayConstants {
    /**
     * 支付宝appid
     */
    public static final String ALI_PAY_APP_ID = "2021004122663556";


    /** 私钥 */
    public static final String privateKey= "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCO7I1C99uGie1zr43YnSM52O9V4MySAnMW/P0iI2WZQx4wEamQTWNKM1p5J505/X/BXJTVHa596IRCPZiR7obcm3Zbzm0J+0kBs/4xdsyrAseMs41KdORbdIHCM5hhMG5wH2tYOH8xB8+Wx4gN843SpVCn1wpM1C14Wne7H2LfJZ3tNWwikx/tjKxQXV3uoIXrYchOb2f56vVrq/L1CM1peMpkO+rvlujvtm2erudOJyFqahmKhkpXPi5yc23fqw6+n0tSB+DvPmWx4NiR/k3SfnAH1fuRLGIKULbbosgQC5MsHQqUaDroq5ZvyEAu5zHd32zrLNpWGZIvRTa+BGe7AgMBAAECggEANtR9JPHdX/HODJGOw0kVWH3m43VIRcN2z5zip5QYyAE9tYcxG9D0hGTLEqul37dmqZGQ72lhpZ/sDVWAEIwHZN6nO3Un06p5SZP5spQ21GxOjaXcUHIjoQpDNXOBw9dGpvEGx2N1OCQc+WU2xtNm1ybgmGMg6nSDtSZPxJO35I8A7w90eSSOQPsvkJEJbIuxpv4khgb0fMN1qfNbRDp3SaUW4FzK4H/hN/H9bIYw5KQptGPH8LXICKThwHstc/JJUZs9kkxqp1F7fMI57G6ie6knkwZRHpL4EKAqscgKZ8HaipsrbYcS45sBDXZoGdVzk0jdLFDjXAIA9CLuGFbmkQKBgQDHnuYT+TCU+tC2qNz8srGZp9ahAOz2r+mvOW0svg/EPpvg0dev7ZYREEbCQc6Ev2BZw7aVOMe8J3TIuCWugmhgTIgEvSrevygZx3nRn2BK3f2ywmfWSNottw1Va+dKJSUqrl4kJoCppFuL5vL2Tyi0bFoFtUUGvVIEW5NHds4qrwKBgQC3SlW+WAI++Txz9NbOXu2eGTqEBRQ0hlhTzj73LMCsGe+0D1m1uwFqlEeO3ixua/FWeyB2cjpxxir/5GhdRzqasX/vtkLM1gOnrMM1ou0JQ9iUF7vavW97VvzOBQQMTpnldmBzM2nAm2RBmEuRrRpB+NukNchjJ/zrTDuTKEnmtQKBgQCOvoGoJrkmz3QQKhBcYyu8xNglqZPJk2F3e4kmRYLgwiSVT3j8xNhau1jd8FDNfExZ5Cnb6w5o7Y4FOik38OjSc+eP+/V78xWp2Yqy61TgNH4GJh46jT33Er7mJpLt4kIBk06eayn2JSGRmUSD/XcODa0SB92kRB0yIIngwIQM4QKBgE9u5a3yEjccaHiQWS9isHPd1yAz20fQGSNotJ0GRhHPw7QzGtvJSZnY3RIrcvH/0b166tyqMG3yRdxULm6OWfWEiz9lq5l9/mOCWa87BqMHRisYBg+MHW5Eipb2UYTL46IwJSiH1YLlVROgXs+pR0HkCbwmmstuHwwSI5do1G4pAoGADYMPo9vqpSYIOQBcjDNcv+XKLEdPKXm04JSkd/Ukb72Eh9pxjy9UkKg6bv1VY8Oz86/2u6wVVaxOJrMtsrGLb1ZoJscizRtj/LQzICvhtAtnfruZVtNM70ZKIkWF5hZJBYtmUog0g4ABjIi3A5WhNdDuOYAPk6av7wB7+Qidqz8=";


    /** 应用公钥路径 */
//    public static final String appCertPublicKeyUrl = "E:\\huizhu\\搭兑\\附件\\appCertPublicKey_2021004122663556.crt";
    public static final String appCertPublicKeyUrl = "/www/SpringBootProjects/dadui/cret/appCertPublicKey_2021004122663556.crt";

    /**
     * 支付宝商户私钥
     */
    public static final String ALI_PAY_MERCHANT_PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCO7I1C99uGie1zr43YnSM52O9V4MySAnMW/P0iI2WZQx4wEamQTWNKM1p5J505/X/BXJTVHa596IRCPZiR7obcm3Zbzm0J+0kBs/4xdsyrAseMs41KdORbdIHCM5hh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B92kRB0yIIngwIQM4QKBgE9u5a3yEjccaHiQWS9isHPd1yAz20fQGSNotJ0GRhHPw7QzGtvJSZnY3RIrcvH/0b166tyqMG3yRdxULm6OWfWEiz9lq5l9/mOCWa87BqMHRisYBg+MHW5Eipb2UYTL46IwJSiH1YLlVROgXs+pR0HkCbwmmstuHwwSI5do1G4pAoGADYMPo9vqpSYIOQBcjDNcv+XKLEdPKXm04JSkd/Ukb72Eh9pxjy9UkKg6bv1VY8Oz86/2u6wVVaxOJrMtsrGLb1ZoJscizRtj/LQzICvhtAtnfruZVtNM70ZKIkWF5hZJBYtmUog0g4ABjIi3A5WhNdDuOYAPk6av7wB7+Qidqz8=";

    /**
     * 支付宝公 证书(  不是应用公钥)
     */
    public static final String ALI_PAY_PUBLIC_KEY = "/www/SpringBootProjects/dadui/cret/alipayCertPublicKey_RSA2.crt";
//    public static final String ALI_PAY_PUBLIC_KEY = "E:\\huizhu\\搭兑\\附件\\alipayCertPublicKey_RSA2.crt";


    /** 请填写您的支付宝根证书文件路径 */
//    public static final String alipayRootCert = "E:\\huizhu\\搭兑\\附件\\alipayRootCert.crt";
    private static final String alipayRootCert = "/www/SpringBootProjects/dadui/cret/alipayRootCert.crt";
    /**
     * 支付宝请求接口
     */
    public static final String ALI_PAY_GATEWAY_URL = "https://openapi.alipay.com/gateway.do";
    /**
     * 编码
     */
    public static final String PAY_CHARSET = "utf-8";
    /**
     * 签名类型
     */
    public static final String ALI_PAY_SIGN_TYPE= "RSA2";
    /**
     * json
     */
    public static final String PAY_JSON= "json";


    /**
     * 微信支付访问路径
     */
    public static final String WX_PAY_UNIFIEDORDER_URL= "https://api.mch.weixin.qq.com/pay/unifiedorder";

    /**
     * 微信appid
     */
    public static final String WX_PAY_APP_ID= "wx302a21a567359e7c";

    public static final String WX_PAY_MCH_ID= "wx302a21a567359e7c";

    /**
     * 加密 签名(证书模式)
     * @return
     * @throws AlipayApiException
     */
    public static  AlipayClient getAlipayClient() throws AlipayApiException {
        /** 初始化 **/
        CertAlipayRequest certAlipayRequest = new CertAlipayRequest();
        /** 支付宝网关 **/
        certAlipayRequest.setServerUrl("https://openapi.alipay.com/gateway.do");
        /** 应用id，如何获取请参考：https://opensupport.alipay.com/support/helpcenter/190/201602493024 **/
        certAlipayRequest.setAppId(ALI_PAY_APP_ID);
        /** 应用私钥, 如何获取请参考：https://opensupport.alipay
         * .com/support/helpcenter/207/201602471154?ant_source=antsupport  **/
        certAlipayRequest.setPrivateKey(ALI_PAY_MERCHANT_PRIVATE_KEY);
        /** 应用公钥证书路径，下载后保存位置的绝对路径  **/
        certAlipayRequest.setCertPath(appCertPublicKeyUrl);
        /** 支付宝公钥证书路径，下载后保存位置的绝对路径 **/
        certAlipayRequest.setAlipayPublicCertPath(ALI_PAY_PUBLIC_KEY);
        /** 支付宝根证书路径，下载后保存位置的绝对路径 **/
        certAlipayRequest.setRootCertPath(alipayRootCert);
        /** 设置签名类型 **/
        certAlipayRequest.setSignType("RSA2");
        /** 设置请求格式，固定值json **/
        certAlipayRequest.setFormat("json");
        /** 设置编码格式 **/
        certAlipayRequest.setCharset("UTF-8");
        return new DefaultAlipayClient(certAlipayRequest);
    }


}
